package com.example.Annocation.Aware;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.EmbeddedValueResolverAware;
import org.springframework.stereotype.Component;
import org.springframework.util.StringValueResolver;

/**
 * @Description TODO
 * @Date 2024/5/15 18:32
 * @Created by houjunfeng
 */
@Component
public class MyAware implements ApplicationContextAware, BeanNameAware, EmbeddedValueResolverAware {
    public ApplicationContext applicationContext;

    @Override
    public void setApplicationContext(ApplicationContext var1) throws BeansException{
        this.applicationContext = var1;
        System.out.println(var1);
    }

    @Override
    public void setBeanName(String var1){
        System.out.println("当前bean的名字："+var1);
    }
    //这个玩意可以帮助我们解析占位符
    @Override
    public void setEmbeddedValueResolver(StringValueResolver var1){
        String stringValueResolver = var1.resolveStringValue("你好${os.name}  我是#{20*18}");
        System.out.println(stringValueResolver);

    }
}
